<?php

class BaseController extends SBaseController
{
 public $pageDescription = null; //Default
 public $pageKeywords    = null; //Default
 public $metaRobots      = null; //Default
 
 public function grbac_crypt($algo,$password,$salt) {
    if (!function_exists('hash')) {
      $cypted = md5($password.$salt);
    }
    else {
      $cypted = hash($algo, $password.$salt);
    }
    return $cypted;
  }

 public function grbac_sendEmail($to, $subject, $emailText) {
    if ($this->module->useEmailExtension == 'mailer') {
        $mailer = Yii::createComponent('application.extensions.mailer.EMailer');
        $mailer->IsSMTP();          // set mailer to use SMTP
        $mailer->SMTPAuth = true;   // turn on SMTP authentication
        $mailer->Host = "smtp.gmail.com"; // specify main and backup server
        $mailer ->SMTPSecure= "ssl"; //  Used instead of TLS when only POP mail is selected
        $mailer->Port = 465;        //  Used instead of 587 when only POP mail is selected
        $mailer->Username = Yii::app()->params['emailAccount'];  // SMTP username, you could use your google apps address too.
        $mailer->Password = Yii::app()->params['emailPassword']; // SMTP password
        $mailer->From = Yii::app()->params['emailAccount'];
        $mailer->CharSet = 'UTF-8';
        $mailer->IsHTML(true);
        $mailer->AddAddress($to);
        $mailer->Subject = $subject;
        $mailer->Body = $emailText;
        $mailer->Send();
    } else {
      // Test mode: if not set, display content on screen
         print_r($emailText);
    }
  }
}